package com.rd.student.jiaji.class1.wangyufang.day0802;

abstract public class Animal {
    String name;

    public Animal(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    abstract void voice();

    abstract void enjoy();
}

class Cat extends Animal {
    String eyeColor;

    public Cat(String name, String eyeColor) {
        super(name);
        this.eyeColor = eyeColor;
    }

    @Override
    void enjoy() {
        System.out.println("笑一笑");
        System.out.println("猫猫眼睛的颜色为：" + eyeColor);
    }

    @Override
    void voice() {
        System.out.print("猫");
    }
}

class Pig extends Animal {
    public Pig(String name) {
        super(name);
    }

    @Override
    void enjoy() {
        System.out.println("拱一拱");

    }

    @Override
    void voice() {

        System.out.print("猪");

    }
}

class Dog extends Animal {
    String furColor;

    public Dog(String name, String furColor) {
        super(name);
        this.furColor = furColor;
    }

    @Override
    void enjoy() {
        System.out.println("叫一叫");
        System.out.println("狗狗父亲的颜色为：" + furColor);
    }

    @Override
    void voice() {
        System.out.print("狗");

    }
}

class Store {
    static Animal getInstance(String type) {
        if (type.equals("dog")) {
            return new Dog("狗狗", "白色");

        }
        if (type.equals("pig")) {
            return new Pig("小猪");
        } else {
            return new Cat("猫猫", "蓝色");
        }
    }
}

class Lady {
    String name;
    Animal pet;

    public Lady(String name, Animal pet) {
        this.name = name;
        this.pet = pet;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Animal getPet() {
        return pet;
    }

    public void setPet(Animal pet) {
        this.pet = pet;
    }

    public void myPetEnjoy() {
        pet.enjoy();
    }

    public void myPetName() {
        pet.voice();
    }
}